<template>
  <div>
    <el-table :data="users">
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="mobile" label="账号"> </el-table-column>
      <el-table-column prop="create_time" label="注册时间"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleClick(scope.row.id)">配置</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="角色配置" :visible.sync="dialogTableVisible">
        <el-radio v-model="radio" :label="i.id" v-for="(i,x) in roles" :key="x">{{ i.name }}</el-radio>
        <el-button @click="tj">提交</el-button>
    </el-dialog>
  </div>
</template>

<script>

export default {
    data(){
        return{
            users:"",
            roles:"",
            uid:"",
            dialogTableVisible:false,
            radio:0

        }
    },
    mounted(){
        this.getuser(),
        this.getrole()
    },
    methods:{
        getuser(){
            this.axios.get("/getuser").then(res =>{
                this.users = res.data.data
            })
        },
        handleClick(id){
            this.uid = id
            this.dialogTableVisible = true
        },
        getrole(){
            this.axios.get("/getroles").then(res =>{
                this.roles = res.data.data
            })
        },
        tj(){
            var data = {"uid":this.uid,"roleid":this.radio}
            this.axios.post("/setuser",data).then(res =>{
                alert(res.data.msg)
            })
        }
    }

}
</script>

<style>

</style>